Skip to content
  • 0 Votes
    2 Posts
    742 Views
    VRoninV

    You can't read from a finished program. you have to connect to readyRead();

    replace

    process->start(cmd,comandlist,QIODevice::ReadOnly ); if (!process->waitForFinished()) { lstr = QString(); } else { lstr = QString(process->readAll().constData()); } return lstr;

    with

    QObject::connect(process,&QProcess::readyReadStandardOutput,[&lstr,process]()->void{lstr.append(QString::fromLatin1(process->readAllStandardOutput()));}); process->start(cmd,comandlist,QIODevice::ReadOnly ); if (process->waitForFinished()) return lstr; return QString();